﻿$(document).ready(function() {
$("#form_changepassword").validate(
        {
            rules: {               
                currentPassword: {
                    required: true,
                    minlength: 6
                },
                 newpassword: {
                    required: true,
                    minlength: 6
                },
                confirmPassword: {
                    required: true,
                    confirmWith: "newpassword"
                }                
            },
            messages: {           
                currentPassword: {
                    required: "请输入原密码",
                    minlength: "密码最少6位"
                },
                newpassword: {
                    required: "请输入新密码",
                    minlength: "密码最少6位"
                },
                confirmPassword: {
                    required: "请重复输入一遍上面输入的密码"
                }

            },
            success: function(label) {
                // set &nbsp; as text for IE
                label.html("&nbsp;").addClass("checked");
            }
        });
});

jQuery.validator.addMethod("confirmWith", function(value, element, param) {
    var result = false;
    var p = $('#' + param);
    if (p) {
        result = (p.val() == value);
    }
    return result;
}, "两次密码输入不一致");